package hot100;

import java.util.HashMap;
import java.util.Map;

public class twoSum {
        public int[] twoSum(int[] nums, int target) {
            Map<Integer,Integer> hash = new HashMap<>();
            int[] ret = new int[2];
            for(int i = 0;i < nums.length;i++) {
                if(hash.containsKey(target-nums[i])) {
                    ret[0] = hash.get(target-nums[i]);
                    ret[1] = i;
                    return ret;
                }
                hash.put(nums[i],i);
            }
            return ret;

    }
}
